﻿#region Imports
using System;
using System.Collections.ObjectModel;
using System.Globalization;
using System.Windows.Data;
using LinqDemo.ViewModels;
#endregion

namespace LinqDemo.Converters
{
    public class DataFilterConverter : IValueConverter
    {
        #region Methods
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            MainViewModel vm = (MainViewModel)value;
            Type T = vm.GetType().GetProperty((string)parameter).PropertyType;

            if (!String.IsNullOrEmpty((string)parameter))
                return vm.GetType().GetProperty((string)parameter).GetValue(vm, null);
            else return null; // new ObservableCollection<T>();
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
        #endregion
    }
}
